package model

type CurrentRaw struct {
	SlaveID uint8   `json:"slaveID"` // 机组地址, 从站ID
	D40001  float64 `json:"D40001" gorm:"column:D40001"`
	D40002  float64 `json:"D40002" gorm:"column:D40002"`
	D40003  float64 `json:"D40003" gorm:"column:D40003"`
	D40004  float64 `json:"D40004" gorm:"column:D40004"`
	D40005  float64 `json:"D40005" gorm:"column:D40005"`
	D40006  float64 `json:"D40006" gorm:"column:D40006"`
	D40007  float64 `json:"D40007" gorm:"column:D40007"`
	D40008  float64 `json:"D40008" gorm:"column:D40008"`
	D40009  uint16  `json:"D40009" gorm:"column:D40009"`
	D40010  uint16  `json:"D40010" gorm:"column:D40010"`
	D40011  uint16  `json:"D40011" gorm:"column:D40011"`

	D40020 int16 `json:"D40020" gorm:"column:D40020"`
	D40021 int16 `json:"D40021" gorm:"column:D40021"`
	D40022 int16 `json:"D40022" gorm:"column:D40022"`
	D40023 int16 `json:"D40023" gorm:"column:D40023"`
	D40024 int16 `json:"D40024" gorm:"column:D40024"`
	D40025 int16 `json:"D40025" gorm:"column:D40025"`
	D40026 int16 `json:"D40026" gorm:"column:D40026"`
	D40027 int16 `json:"D40027" gorm:"column:D40027"`
}

func (c *CurrentRaw) ChangeToPointItem() (pointItem []*PointItem) {
	pointItem = []*PointItem{
		{
			Title:    "1#电流",
			Addr:     "D40001",
			Value:    c.D40001,
			DataType: "float32",
		},
		{
			Title:    "2#电流",
			Addr:     "D40002",
			Value:    c.D40002,
			DataType: "float32",
		},
		{
			Title:    "3#电流",
			Addr:     "D40003",
			Value:    c.D40003,
			DataType: "float32",
		},
		{
			Title:    "4#电流",
			Addr:     "D40001",
			Value:    c.D40001,
			DataType: "float32",
		},
		{
			Title:    "5#电流",
			Addr:     "D40001",
			Value:    c.D40001,
			DataType: "float32",
		},
		{
			Title:    "6#电流",
			Addr:     "D40001",
			Value:    c.D40001,
			DataType: "float32",
		},
		{
			Title:    "7#电流",
			Addr:     "D40007",
			Value:    c.D40007,
			DataType: "float32",
		},
		{
			Title:    "8#电流",
			Addr:     "D40008",
			Value:    c.D40008,
			DataType: "float32",
		},
		{
			Title:    "从站ID",
			Addr:     "D40009",
			Value:    float64(c.D40009),
			DataType: "uint16",
		},
		{
			Title:    "波特率",
			Addr:     "D40010",
			Value:    float64(c.D40010),
			DataType: "uint16",
		},
		{
			Title:    "校验方式",
			Addr:     "D40011",
			Value:    float64(c.D40011),
			DataType: "uint16",
		},
		{
			Title:    "1#电流修正",
			Addr:     "D40020",
			Value:    float64(c.D40020),
			DataType: "int16",
		},
		{
			Title:    "2#电流修正",
			Addr:     "D40021",
			Value:    float64(c.D40021),
			DataType: "int16",
		},
		{
			Title:    "3#电流修正",
			Addr:     "D40022",
			Value:    float64(c.D40022),
			DataType: "int16",
		},
		{
			Title:    "4#电流修正",
			Addr:     "D40023",
			Value:    float64(c.D40023),
			DataType: "int16",
		},
		{
			Title:    "5#电流修正",
			Addr:     "D40024",
			Value:    float64(c.D40024),
			DataType: "int16",
		},
		{
			Title:    "6#电流修正",
			Addr:     "D40025",
			Value:    float64(c.D40025),
			DataType: "int16",
		},
		{
			Title:    "7#电流修正",
			Addr:     "D40026",
			Value:    float64(c.D40026),
			DataType: "int16",
		},
		{
			Title:    "8#电流修正",
			Addr:     "D40027",
			Value:    float64(c.D40027),
			DataType: "int16",
		},
	}
	for _, row := range pointItem {
		row.Module = 1
	}
	return
}
